<?php
/**
 * <https://y.st./>
 * Copyright © 2017 Alex Yst <mailto:copyright@y.st>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <https://www.gnu.org./licenses/>.
**/

$xhtml = array(
	'<{title}>' => 'Library database relations',
	'<{subtitle}>' => 'Written in <span title="Databases 1">CS 2203</span> of <a href="http://www.uopeople.edu/">University of the People</a>, finalised on 2017-06-21',
	'<{copyright year}>' => '2017',
	'takedown' => '2017-11-01',
	'<{body}>' => <<<END
<h2><code>Book</code>:</h2>
<p>
	The <code>Book</code> relation will include the following attributes in its tuples:
</p>
<ul>
	<li>
		<code>id</code> (integer, unique, primary key, auto-increment, not null, candidate key)
	</li>
	<li>
		<code>title</code> (string, not null)
	</li>
	<li>
		<code>author</code> (string, not null)
	</li>
	<li>
		<code>isbn</code> (string, not null)
	</li>
	<li>
		<code>publication_date</code> (string, not null)
	</li>
	<li>
		<code>cost</code> (float, not null)
	</li>
</ul>
<p>
	This relation has a relation degree of six.
</p>
<p>
	<code>id</code> will be the primary key, and will auto-increment as books are added.
	This attribute will be an integer.
	It&apos;s <strong>*extremely*</strong> tempting to use the <code>isbn</code> attribute as the primary key, but there could be multiple copies of the same book in the library&apos;s collection.
	If there are multiple copies of any book, no field will be unique unless we add this artificial key.
</p>
<p>
	<code>title</code> will be a string.
	Obviously, it&apos;ll be the title of the book.
	<code>author</code> too will be a string, the author of the book.
	This will be in &quot;{given name} {surname}&quot; format, <strong>*not*</strong> &quot;{surname}, {given name}&quot; format.
	The proper format of an $a[ISBN] includes three hyphens, so to accommodate this, the <code>isbn</code> attribute is a string, not an integer.
	<code>publication_date</code> is the date of the book&apos;s publication in the <code>*international standard format*</code>, which happens to be big endian.
	That is to say, if the book were published today, the <code>publication_date</code> would be set to <code>2017-06-21</code>, not something goofy such as <code>06-21-2017</code>.
	This field is a string to accommodate use of hyphens as well.
	The cost of the book wil be stored in the <code>cost</code> attribute.
	This field is a floating-point decimal to allow for partial currency units.
	In the United States, dollars would be the whole units and cents would be represented by hundredths of units.
	As this is a floating-point decimal and not a string, a currency sign such as a dollar sign is not included.
</p>
<h2><code>Borrower</code>:</h2>
<p>
	The <code>Borrower</code> relation will have the following attributes in its tuples:
</p>
<ul>
	<li>
		<code>card_number</code> (integer, unique, primary key, not null, candidate key)
	</li>
	<li>
		<code>name</code> (string, not null)
	</li>
	<li>
		<code>address</code> (string, not null)
	</li>
	<li>
		<code>postal_code</code> (integer, not null)
	</li>
	<li>
		<code>telephone_number</code> (string)
	</li>
	<li>
		<code>join_date</code> (string, not null)
	</li>
</ul>
<p>
	This relation has a relation degree of seven.
</p>
<p>
	<code>card_number</code> will be an integer set to the cardholder&apos;s library card number.
	These numbers will likely not be sequential, but they will be unique.
	This field will be used as the primary key.
	<code>name</code> will be a string attribute used to store the cardholder&apos;s name.
	<code>address</code> will store their postal address as a string, excluding the postal code.
	<code>postal_code</code> will be an integer storing the postal code of each cardholder.
	<code>telephone_number</code> will be used to store the cardholder&apos;s telephone number.
	Not everyone has telephone service though.
	To allow for this, the <code>telephone_number</code> attribute can be null, unlike other attributes of these relations.
	<code>join_date</code> will be a string, using the international, standard date format.
</p>
<h2><code>BookLended</code>:</h2>
<p>
	The tuples of the <code>BookLended</code> relation will have these attributes:
</p>
<ul>
	<li>
		<code>book</code> (integer, unique, primary key, foreign key, not null, candidate key)
	</li>
	<li>
		<code>checked_out</code> (string, not null)
	</li>
	<li>
		<code>due_back</code> (string, not null)
	</li>
	<li>
		<code>borrower</code> (integer, foreign key, not null)
	</li>
	<li>
		<code>librarian</code> (integer, foreign key, not null)
	</li>
</ul>
<p>
	This relation has a relation degree of five.
</p>
<p>
	The <code>book</code> attribute is a foreign key representing a book that is currently checked out.
	It&apos;s an integer that matched the <code>id</code> of a book in the <code>Books</code> relation.
	Because a book cannot be checked out by two people at once, the <code>book</code> also serves as the primary key of the <code>BookLended</code> relation.
	<code>checked_out</code> and <code>due_back</code> are the dates the book was checked out and will be due back, respectively.
	As before, the international, standard, big-endian format is used here.
	<code>borrower</code> is an integer that acts as a foreign key to the <code>Borrower</code> relation.
	This represents the cardholder that currently has the book in their possession.
	The <code>librarian</code> attribute is an integer and a foreign key representing the $a[ID] number of the librarian that checked out the book.
</p>
<h2><code>Librarian</code>:</h2>
<p>
	The attributes of the <code>Librarian</code> relation are as follows:
</p>
<ul>
	<li>
		<code>id</code> (integer, unique, primary key, not null, candidate key)
	</li>
	<li>
		<code>name</code> (string, not null)
	</li>
	<li>
		<code>extension</code> (integer, unique, alternate key, not null, candidate key)
	</li>
</ul>
<p>
	This relation has a relation degree of three.
</p>
<p>
	The primary key of this relation is the librarians&apos; $a[ID] numbers, stored as the <code>id</code> property.
	However, as each librarian has their own extension, the <code>extension</code> field both stores that extension and acts as an alternate key.
	While our borrowers may not all have telephone numbers, all of our librarians are reachable by telephone, so this attribute cannot be null.
	This is because we&apos;re using the library&apos;s internal telephone setup, not relying on the librarians to be subscribed to telephone service.
	The librarian&apos;s name is stored using the <code>name</code> key.
</p>
END
);
